package com.app.service.impl;


import com.app.mapper.JobFairSceneMapper;
import com.app.mapper.SchoolMapper;
import com.app.model.EnterpriseModel;
import com.app.model.JobFairSceneModel;
import com.app.model.SchoolModel;
import com.app.service.JobFairSceneService;
import com.app.service.SchoolService;
import com.app.util.StringTool;
import com.app.vo.JobFairSceneVo;
import com.app.vo.SchoolVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.List;

@Service
public class SchoolServiceImpl implements SchoolService {

    @Resource
    private SchoolMapper schoolMapper;


    @Override
    public SchoolVo bakGetSchoolList(SchoolModel model) {
        QueryWrapper<SchoolModel> queryWrapper = new QueryWrapper<>();

        if (StringTool.isNotEmpty(model.getSchoolName())) {
            queryWrapper.like("school_name", model.getSchoolName());
        }
        Page<SchoolModel> pages = new Page<>();
        pages.setCurrent(model.getPage());
        pages.setSize(model.getLimit());
        Page<SchoolModel> page = schoolMapper.selectPage(pages, queryWrapper);
        if (page == null) {
            return null;
        } else {
            SchoolVo vo = new SchoolVo();
            vo.setList(page.getRecords());
            vo.setCount((int)page.getTotal());
            return vo;
        }
    }

    @Override
    public SchoolModel getModelById(Integer id) {
        return schoolMapper.selectById(id);
    }

    @Override
    public Integer insert(SchoolModel model) {
        return schoolMapper.insert(model);
    }

    @Override
    public void update(SchoolModel model) {
        schoolMapper.updateById(model);
    }

    @Override
    public void delete(Integer id) {
        schoolMapper.deleteById(id);
    }
}
